package com.yexiao.cofe.business.controller;

import com.alibaba.fastjson2.JSONObject;
import com.yexiao.cofe.business.service.StoreService;
import com.yexiao.cofe.resolver.IRequestParam;
import com.yexiao.cofe.resolver.IRequestToken;
import com.yexiao.core.response.ResponseData;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * @author lkl
 * @since 2025/4/1
 */
@RestController
@RequestMapping("/store")
public class StoreController {

    @Resource
    private StoreService storeService;

    @GetMapping("/listAll")
    public ResponseData listAll(@IRequestParam JSONObject param, @IRequestToken String token) {
        return ResponseData.success(storeService.listAll(param, token));
    }

    @PostMapping("/add")
    public ResponseData add(@RequestBody JSONObject param, @IRequestToken String token) {
        storeService.addStore(param, token);
        return ResponseData.success();
    }

    @PostMapping("/modify")
    public ResponseData modify(@RequestBody JSONObject param, @IRequestToken String token) {
        storeService.modify(param, token);
        return ResponseData.success();
    }

    @GetMapping("/listProduct")
    public ResponseData listProduct(@IRequestParam JSONObject param, @IRequestToken String token) {
        return ResponseData.success(storeService.listProduct(param, token));
    }

    @GetMapping("/detail")
    public ResponseData detail(@IRequestParam JSONObject param, @IRequestToken String token) {
        return ResponseData.success(storeService.detail(param, token));
    }

    @PostMapping("/modifyStatus")
    public ResponseData modifyStatus(@RequestBody JSONObject param, @IRequestToken String token) {
        storeService.modifyStatus(param, token);
        return ResponseData.success();
    }

    @PostMapping("/bindProduct")
    public ResponseData bindProduct(@RequestBody JSONObject param, @IRequestToken String token) {
        storeService.bindProduct(param, token);
        return ResponseData.success();
    }

    @GetMapping("/copyProduct")
    public ResponseData copyProduct(@IRequestParam JSONObject param, @IRequestToken String token) {
        storeService.copyProduct(param, token);
        return ResponseData.success();
    }

    @GetMapping("/changeTemplate")
    public ResponseData changeTemplate(@IRequestParam JSONObject param, @IRequestToken String token) {
        storeService.changeTemplate(param, token);
        return ResponseData.success();
    }

    @GetMapping("/storeProductDetail")
    public ResponseData storeProductDetail(@IRequestParam JSONObject param, @IRequestToken String token) {
        return ResponseData.success(storeService.storeProductDetail(param, token));
    }

    @GetMapping("/delStoreProduct")
    public ResponseData delStoreProduct(@IRequestParam JSONObject param, @IRequestToken String token) {
        storeService.delStoreProduct(param, token);
        return ResponseData.success();
    }
}
